import json
from script.get_contest_info.response.nc_ioi_response import get_nc_ioi_response

# 将返回两个值表示 uid 在 contest_id IOI 竞赛中的 AC 次数和总得分（总得分*100）
def nc_ac_and_score(contest_id, uid):
    # 这里假设get_nc_ioi_response返回的是一个JSON格式的字符串
    response_str = get_nc_ioi_response(contest_id, uid)
    try:
        # 将字符串解析为字典
        response = json.loads(response_str)
        rank_data_accepted_count = response["data"]["rankData"][0]["acceptedCount"] if "rankData" in response["data"] and \
                                                                                   response["data"]["rankData"] else None
        rank_data_full_score = response["data"]["rankData"][0]["fullScore"] if "rankData" in response["data"] and \
                                                                               response["data"]["rankData"] else None
        return rank_data_accepted_count, rank_data_full_score
    except json.JSONDecodeError:
        print("无法解析JSON数据")
        return None, None


if __name__ == '__main__':
    print(nc_ac_and_score(91283, "710192458"))
